const fs = require("fs")

function writeData(path, data) {
    return new Promise((res, rej) => {
        fs.writeFile(path, JSON.stringify(data), err => {
            if (err) {
                rej(err.message)
            }
        })
    })
}

function readDate(path, data) {
    return new Promise((res, rej) => {
        fs.readFile(path, "utf-8", (err, data) => {
            if (err) {
                rej(err.message)
            }
            res(data)
        })
    })
}

module.exports = {
    writeData,
    readDate
}